package gbackup.command;

import core.Directory;
import core.File;
import core.Shell;

public class ListCommand extends Command {

	private Directory _workingDirectory = null;

	public ListCommand(Shell shell, String rawCommand) {
		super(shell, rawCommand);
		this._workingDirectory = this._shell.getWorkingDirectory();
	}

	@Override
	public void execute() {
		// TODO: list specific directory
		if (this._arguments.size() != 0) {
			this._outputPrintStream.println("Invalid Argument : [" + this._rawCommand + "]");
			return;
		}

		for (File f : this._workingDirectory.getChildern()) {
			if (f.isDirectory())
				this._outputPrintStream.println(f.getName() + File.FILE_SEPERATOR);
			else
				this._outputPrintStream.println(f.getName());
		}
	}

	public void setWorkingDirectory(Directory workingDirectory) {
		this._workingDirectory = workingDirectory;
	}
}
